package com.sgb.kjwl.view.ui.activity.toBeReviewed;

import android.content.Context;
import androidx.databinding.ViewDataBinding;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.sgb.kjwl.BR;
import com.sgb.kjwl.R;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;

import java.util.List;

public class ReviewListAdapter extends BaseRecycleAdapter<MemberApplyEntry> {
    private ImageView imageView;
    private TextView tv_agree;
    private ItemChildClick itemChildClick;
    public ReviewListAdapter(Context context, List<MemberApplyEntry> data) {
        super(context, R.layout.item_review_list, data);
    }


    @Override
    public void convert(ItemViewHolder holder, MemberApplyEntry memberApplyEntry) {
        holder.setBinding(BR.viewModel, memberApplyEntry);
        imageView = holder.itemView.findViewById(R.id.img_status);
        tv_agree = holder.itemView.findViewById(R.id.tv_agree);
        if(memberApplyEntry.getStatus()==2){
            imageView.setImageResource(R.drawable.agree);
            imageView.setVisibility(View.VISIBLE);
        }else if(memberApplyEntry.getStatus()==3){
            imageView.setImageResource(R.drawable.noagree);
            imageView.setVisibility(View.VISIBLE);
        }else{
            imageView.setVisibility(View.INVISIBLE);
        }

        tv_agree.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(itemChildClick!=null){
                    itemChildClick.onItemClick(memberApplyEntry,imageView,tv_agree,holder.getAdapterPosition());
                }
            }
        });
    }

    public interface ItemChildClick {
        void onItemClick(MemberApplyEntry memberApplyEntry,ImageView statusImg,TextView textView,int position);
    }

   public void setiIemChildClickListener(ItemChildClick listener){
       this.itemChildClick = listener;
   }


}
